home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1994 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  52 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.sprintlink.net!eskimo!news
  3. From: mag@eskimo.com (mAg)
  4. Subject: Re: Help, best way to compare doubles
  5. X-Nntp-Posting-Host: tia1.eskimo.com
  6. Message-ID: <DLD5Kp.JME@eskimo.com>
  7. Sender: news@eskimo.com (News User Id)
  8. Organization: *.*
  9. X-Newsreader: WinVN 0.93.10
  10. References: <4da169$mm4@mercury.IntNet.net> <4dfdtl$phv@nntp.crl.com>
  11. Date: Thu, 18 Jan 1996 06:19:36 GMT
  12.  
  13. In article <4dfdtl$phv@nntp.crl.com> (16 Jan 1996 05:43:17 GMT), 
  14. bivey@ecf2.puc.edu says :
  15. >
  16. >Jeff Tomich (jtomich@IntNet.net) wrote:
  17. >: Looking for a way to compare doubles for equality.
  18. >
  19. >: thanks, Jeff
  20. >
  21. >The first question to ask is "how equal"?  In general, one picks some
  22. >error limit, such as  e = 1E-6;   then uses it in this form:
  23. >
  24. >   if (fabs(n1 - n2) < e)  // then they are considered equal
  25. >   else                    // they are considered different
  26. >
  27.  
  28. "How equal" is irrelevant. "Equal to" comparison produces a boolean result 
  29. True or False. 
  30.  
  31. '==' is good enough
  32.  
  33.  
  34. >--------------------------------------------------------------------------
  35. ---
  36. >Bruce Ivey         Dept of Physics & Computer Science   Pacific Union 
  37. College
  38. >Angwin, CA 94508            bivey@puc.edu                      (707) 
  39. 965-7269
  40. >==========================================================================
  41. ===
  42.  
  43. -- 
  44. /* --------------------------------------------------------
  45.                       MAG@ESKIMO.COM
  46. http://www.eskimo.com/~mag/index.html
  47. ***********************************************************
  48. To understand recursion one must first understand recursion
  49. ***********************************************************
  50. -------------------------------------------------------- */
  51.  
  52.